There are a lot of built-in themes in ggplot and you can use them in two ways, by stating before your plot to set the theme:
theme_set(theme_bw())
or by adding them to your plot directly:
my_plot + theme_bw()
There is also a great library called ggthemes which adds even more built-in themes for ggplot. You can also customize your own themes, we'll have resources for you to do this at the end of the lecture.
Let's show some simple examples
library(ggplot2)
df <- mtcars
head(df)
pl <- ggplot(df,aes(x=mpg,y=hp)) + geom_point()
print(pl)
pl + theme_bw()
pl + theme_classic()
pl + theme_dark()
pl + theme_get()
pl + theme_light()
pl + theme_linedraw()
pl + theme_minimal()
pl + theme_void()
Here's a link to the documentation for ggthemes. Let's see just a few examples:
library(ggthemes)
pl + theme_excel()
pl + theme_economist()
pl + theme_economist_white()
If you want to make your own custom themes (although I would highly suggest you take the time to research for existing similar themes). YOu can create your own by following the extensive documentation